package org.dromara.common.core.utils;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;


import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class StaticLogger {

    // 使用线程安全的ConcurrentHashMap来存储城市的当前页码
    private static final  ConcurrentHashMap<String, AtomicLong> cityPageMap = new ConcurrentHashMap<>();

    // 默认每页显示的广告数量
    private static final int PAGE_SIZE = 1;

    // 私有方法，用于获取城市的当前页码，如果不存在则初始化为1
    public static long getCurrentPage(String city) {
        return cityPageMap.computeIfAbsent(city, k -> new AtomicLong(1)).get();
    }

    // 私有方法，用于更新城市的当前页码
    public static void updateCurrentPage(String city, long newPage) {
        cityPageMap.computeIfPresent(city, (k, v) -> {
            v.set(newPage);
            return v;
        });
    }





}
